* initremote: Avoid creating a remote that is not encrypted when gpg is
broken.
* Support --json and --json-error-messages in many more commands
- (addunused, dead, describe, dropunused, enableremote, expire, fix,
- importfeed, init, initremote, log, merge, migrate, reinit, reinject,
- rekey, renameremote, rmurl, semitrust, setpresentkey, trust, unannex,
- undo, untrust, unused, upgrade)
+ (addunused, configremote, dead, describe, dropunused, enableremote,
+ expire, fix, importfeed, init, initremote, log, merge, migrate, reinit,
+ reinject, rekey, renameremote, rmurl, semitrust, setpresentkey, trust,
+ unannex, undo, untrust, unused, upgrade)
* log: When --raw-date is used, display only seconds from the epoch, as
documented, omitting a trailing "s" that was included in the output
before.
import qualified Data.Map as M
cmd :: Command
-cmd = command "configremote" SectionSetup
- "changes special remote configuration"
- (paramPair paramName $ paramOptional $ paramRepeating paramParamValue)
- (withParams seek)
+cmd = withAnnexOptions [jsonOptions] $
+ command "configremote" SectionSetup
+ "changes special remote configuration"
+ (paramPair paramName $ paramOptional $ paramRepeating paramParamValue)
+ (withParams seek)
seek :: CmdParams -> CommandSeek
seek = withWords (commandAction . start)
start :: [String] -> CommandStart
start [] = unknownNameError "Specify the remote to configure."
-start (name:rest) = do
- cfg <- safeConfig rest
- deadLast name $ startSpecialRemote name cfg
+start (name:inputconfig) = deadLast name $
+ startSpecialRemote (checkSafeConfig inputconfig) name
+ (Logs.Remote.keyValToConfig Proposed inputconfig)
{- Since this command stores config without calling the remote's setup
- method to validate it, it can only be used on fields that are known to
- be safe to change in all remotes. -}
-safeConfig :: [String] -> Annex Remote.RemoteConfig
-safeConfig cs = do
+checkSafeConfig :: [String] -> Annex ()
+checkSafeConfig cs = do
let rc = Logs.Remote.keyValToConfig Proposed cs
forM_ (M.keys rc) $ \k ->
when (fromProposedAccepted k `notElem` safefields) $
giveup $ "Cannot change field \"" ++ fromProposedAccepted k ++ "\" with this command. Use git-annex enableremote instead."
case SpecialRemote.parseRemoteConfig rc (Remote.RemoteConfigParser ps Nothing) of
Left err -> giveup err
- Right _ -> return rc
+ Right _ -> return ()
where
ps = [ SpecialRemote.autoEnableFieldParser ]
safefields = [ fromProposedAccepted SpecialRemote.autoEnableField ]
-startSpecialRemote :: Git.RemoteName -> Remote.RemoteConfig -> [(UUID, Remote.RemoteConfig, Maybe (SpecialRemote.ConfigFrom UUID))] -> CommandStart
-startSpecialRemote = startSpecialRemote' "configremote" performSpecialRemote
+startSpecialRemote :: Annex () -> Git.RemoteName -> Remote.RemoteConfig -> [(UUID, Remote.RemoteConfig, Maybe (SpecialRemote.ConfigFrom UUID))] -> CommandStart
+startSpecialRemote = startSpecialRemote' "configremote" . performSpecialRemote
-performSpecialRemote :: PerformSpecialRemote
-performSpecialRemote _ u _ c _ mcu = do
+performSpecialRemote :: Annex () -> PerformSpecialRemote
+performSpecialRemote precheck _ u _ c _ mcu = do
+ precheck
case mcu of
Nothing -> Logs.Remote.configSet u c
Just (SpecialRemote.ConfigFrom cu) ->
* git-annex-upgrade
* git-annex-initremote
* git-annex-enableremote
-
-Provisional list of commands that don't support --json and maybe should:
-
* git-annex-configremote
These commands could support json, but I punted:
These commands have been reviewed and should not support json:
+(Discussion welcome of course if you disagree..)
+
* git-annex-contentlocation, git-annex-lookupkey, git-annex-calckey,
(plumbing, output already machine parseable)
* git-annex-setkey (plumbing)